<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
  <title>欢迎页面-X-admin2.2</title>
  <!--/*--> 引入css、jq、layui等样式、js <!--*/-->
  <meta th:include="~{layout/layout_hread :: head}">
</head>
<body>
<div class="layui-form" style="margin: 20px auto;">
  <div class="layui-form-item">
    <label class="layui-form-label">角色名</label>
    <div class="layui-input-inline">
      <input type="text" name="roleName" required lay-verify="required" placeholder="请输入角色名"
             autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">要求 "ROLE_" 开头，全大写命名</div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">角色描述</label>
    <div class="layui-input-block" style="width: 400px;">
      <textarea name="desc" placeholder="请输入角色描述" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
    </div>
  </div>
</div>
<script>
  layui.use(['form', 'layer', 'jquery'],
      function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        //监听提交
        form.on('submit(add)', function (data) {
          $.ajax({
            data: data.field,
            url: '/admin/roleAdd',
            type: 'post',
            success(data) {
              layer.msg(data.message)
              if (data.code == 0) {//添加成功
                window.setTimeout(function () {
                  window.close()
                }, 1500)
              }
            }
          })
          return false;
        });

      });
</script>
</body>

</html>
